package com.jeff.tianti.cms.dao;

import com.jeff.tianti.common.dao.CustomBaseSqlDaoImpl;
import com.jeff.tianti.common.entity.PageModel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jeff.tianti.cms.entity.AwardDescription;
import com.jeff.tianti.cms.dto.AwardDescriptionQueryDTO;
import org.apache.commons.lang3.StringUtils;

/**
 * @author NOW_GO
 * @desc AwardDescriptionDaoImpl类
 * @date 2019-07-15
 */

public class AwardDescriptionDaoImpl extends CustomBaseSqlDaoImpl implements AwardDescriptionDaoCustom {

    public PageModel<AwardDescription> queryAwardDescriptionPage(AwardDescriptionQueryDTO awardDescriptionQueryDTO) {
        Map<String, Object> map = new HashMap<String, Object>();
        StringBuilder hql = new StringBuilder();
        hql.append("select t from AwardDescription t  where 1=1 and t.deleteFlag = 0  ");
        if (awardDescriptionQueryDTO != null) {
            if (StringUtils.isNotBlank(awardDescriptionQueryDTO.getColumnId())) {
                hql.append(" and t.columnId like :columnId ");
                map.put("columnId",  awardDescriptionQueryDTO.getColumnId() );
            }
        }
        hql.append(" order by t.createDate desc ");
        return this.queryForPageWithParams(hql.toString(), map, awardDescriptionQueryDTO.getCurrentPage(), awardDescriptionQueryDTO.getPageSize());
    }

    public List<AwardDescription> queryAwardDescriptionList(AwardDescriptionQueryDTO awardDescriptionQueryDTO) {
        Map<String, Object> map = new HashMap<String, Object>();
        StringBuilder hql = new StringBuilder();
        hql.append("select t from AwardDescription t ");
        return this.queryByMapParams(hql.toString(), map);
    }


}